<template>
	<view>
		<view class="navbar" style="padding: 20rpx;background-color: #fff;height: 180rpx;">
			<view class="title1" style="text-align: center;font-weight: bold;font-size: 45rpx;">首页</view>
			<view class="search" style="width: 95%;height: 64rpx;background-color: #f2f2f2;border-radius: 50rpx;
			border: 2rpx solid #dd6161;display: flex;flex-direction: row;justify-content: start;align-items: center;
			position: relative;margin: 20rpx auto;flex-shrink: 0;">
				<u-icon name="search" style="margin-left: 20rpx;"></u-icon>
				<input type="text" placeholder="请输入关键字" v-model="value" style="margin-left: 20rpx;">
				<button class="bu" style="width: 120rpx;height: 95%;background-color: #fa3534;border-radius: 50rpx;
				position: absolute;right: 1rpx;top: 1rpx;" @click="submit">搜索</button>
			</view>
		</view>
		<scroll-view scroll-y="true" class="main">
			<view class="content">
				<view class="swiper">
					<u-swiper :list="swiperList" @click="to"></u-swiper>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				swiperList: []
			}
		},
		onLoad() {
			this.getSwiper()
		},
		methods: {
			submit(){
				uni.navigateTo({
					url:'/pages/search/search?key=' + this.value
				})
			},
			getSwiper(){
				this.$request({
					url: '/prod-api/api/rotation/list',
					data: {
						type: '2'
					}
				}).then(res => {
					console.log(res)
					this.swiperList = res.rows.map(item => ({image: this.$baseUrl + item.advImg, id: item.targetId}))
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
		view{
			height: 100%;
			display: flex;
			flex-direction: column;
			.main{
				flex: 1;
				overflow: hidden;
				.content{
					height: fit-content;
					background-color: #f7f7f7;
				}
			}
		}
	}
</style>
